import cv2
import pyautogui
import numpy as np
import time
from test1_  import is_same_photo
print('开始获取左上角坐标')
time.sleep(1)
x1,y1 = pyautogui.position()
print('开始获取右下角坐标')
time.sleep(1)
x2,y2 = pyautogui.position()
screenshot = pyautogui.screenshot(region=(x1,y1,x2-x1,y2-y1))
#screenshot.save('screenshot1.png')
imageFirst = cv2.imread(screenshot)
while True:
    screenshot = pyautogui.screenshot(region=(x1,y1,x2-x1,y2-y1))
    #screenshot.save('screenshot2.png')
    imageSecond = cv2.imread(screenshot)
    if is_same_photo(imageFirst,imageSecond):
        pass
    else:
        imageFirst = imageSecond #更新新图片
        
    #每0.5秒截取一张图片与上一张图片进行比较，一旦不匹配就，就执行下一步的操作
    

screenshot.save('screenshot.png')

image = cv2.imread('screenshot.png')

cv2.imshow('test',image)
cv2.waitKey()